package com.luych.toolbox.common.service.base;

import org.springframework.beans.BeanUtils;

import java.util.function.BiConsumer;
import java.util.function.Function;

public interface BaseConvert<Source, Target> extends Function<Source, Target>, BiConsumer<Source, Target> {

    Target target();

    @Override
    default void accept(Source source, Target target) {
        BeanUtils.copyProperties(source, target);
    }

    @Override
    default Target apply(Source source) {
        Target target = this.target();
        this.accept(source, target);
        return target;
    }
}
